#ifndef _QGLOBAL_H
#define _QGLOBAL_H


#include "qansieditor.h"
#include <QtCore/QString>


namespace QAnsiEditor {


class QGlobal
{

public:

    static const char *FILE_SIGN;
    static const char *MIME_ANSITEXT;

    enum Language {
        Chinese_Simpilified,
        Chinese_Traditional,
        English,
    };

    enum Encoding {
        GBK,
        Big5,
        UTF8
    };

    static QGlobal *instance();
    static QTextCodec *getEncodingCodec(Encoding encoding);

    bool showGrid() const;
    void setShowGrid(bool bEnable);
    bool autoFont() const;
    void setAutoFont(bool bEnable);
    bool antiAlias() const;
    void setAntiAlias(bool bEnable);
    Language language() const;
    void setLanguage(Language lang);
    Encoding inputEncoding() const;
    QTextCodec *inputEncodingCodec() const;
    void setInputEncoding(Encoding encoding);
    Encoding outputEncoding() const;
    QTextCodec *outputEncodingCodec() const;
    void setOutputEncoding(Encoding encoding);
    QString asciiFont() const;
    void setAsciiFont(const QString &strAsciiFont);
    QString nonAsciiFont() const;
    void setNonAsciiFont(const QString &strNonAsciiFont);
    QString escapeString() const;
    void setEscapeString(const QString &strEscape);

    /**
     * Initialize default values
     */
    void initSettings();
    void loadSettings();
    void saveSettings();

private:
    QGlobal();
    static QGlobal *m_pInstance;

    bool m_bShowGrid;
    bool m_bAutoFont;  // TODO: auto-size font size, this cannot be changed currently.
    bool m_bAntiAlias;
    Language m_language;
    Encoding m_inputEncoding;
    Encoding m_outputEncoding;
    QString m_strAsciiFont;
    QString m_strNonAsciiFont;
    QString m_strEscape;
    // TODO: need to add row, column, font-size here or anywhere else
};


}  // namespace QAnsiEditor


#endif  // _QGLOBAL_H
